package cn.wolfcode.web.controller;

import cn.wolfcode.common.web.Result;
import cn.wolfcode.domain.Product;
import cn.wolfcode.service.IProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;


@RestController
@RequestMapping("/product")
@Slf4j
public class ProductController {
    @Autowired
    private IProductService productService;

    @RequestMapping("/getProducts")
    public Result<List<Product>> getProducts(@RequestParam("ids") ArrayList<Long> ids){
        List<Product> products=productService.getProductByIds(ids);
        return Result.success("操作成功",products);
    }
    //getProduct
    @RequestMapping("/getProduct")
    public Result<Product> getProduct(Long id){
        Product product=productService.getProductById(id);
        return Result.success("操作成功",product);
    }
}
